<template>
  <v-table :pageSize="pageSize"
           :page="page"
           :tableConfig="tableConfig"
           :tableData="tableData"
           :total="total"
          :style="{height:calcHeight(370) + 'px'}"
           @findData="getTableData"
           @getTableData="getTableData"
           @searhData="setSearhData"
           @selectData="setSelectData"
           @setdialog="setdialog"
           @upData="getTableData"
           ref="table"></v-table>
</template>

<script>
import table from 'commons/Table'
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "Table",
  mixins: [baseMixin],
  props: {
    data: {
      type: Object
    }
  },
  data () {
    return {
      tableConfig: [
        {
          label: this.$t('outbound.userlinenumber'),
          prop: "orderlinenumber",
          input: "input",
        },
        {
          label: this.$t('config.shipper'),
          prop: "storerkey",
          input: "input",
        },
        {
          label: this.$t('config.sku'),
          prop: "sku",
          input: "input",
        },
        {
          label: this.$t('common.desc'),
          prop: "skudescr",
          input: "input"
        },
        {
          label: this.$t('config.packaging'),
          prop: "packkey",
          input: "input",
        },
        {
          label: this.$t('config.measureUnit'),
          prop: "uom",
          input: "input",
        },
        {
          label: this.$t('common.status'),
          prop: "status",
          input: "select",
          options: this.getOptions("queryOrderStatusDropDown")
        },
        {
          label: this.$t('in.returnreason'),
          prop: "shortshipreason",
          input: "select",
          options: this.getOptions("querycodeLkup/SHORTRSNS")
        },
        {
          label: this.$t('in.surplusqty'),
          prop: "openqty",
          input: "input",
        },
        {
          label: this.$t('out.originalqty'),
          prop: "originalqty",
          input: "input",
        },
        {
          label: this.$t('outbound.qtyallocated'),
          prop: "qtyallocated",
          input: "input",
        },
        {
          label: this.$t('outbound.qtypicked'),
          prop: "qtypicked",
          input: "input",
        },
        {
          label: this.$t('out.shippedqty'),
          prop: "shippedqty",
          input: "input",
        },
        {
          label: this.$t('out.qtypreallocated'),
          prop: "qtypreallocated",
          input: "input",
        },
      ],
      tableData: [],
      pageSize: 10,
      page: 1,
      total: 10,
      searhData: {}
    }
  },
  methods: {
    //获取table数据
    async getTableData (page, data) {
      try {
        let res = await this.$api.post(`/queryOrderdetailList/${this.data.argument.orderkey}/${page}`, data);
        
          this.loading = false;
          this.tableData = res.page.list;
          this.pageSize = res.page.pageSize;
          this.page = res.page.curpage;
          this.total = res.page.total;
      } catch (e) {
        this.$message.error(e);
      }
    },
    //搜索值
    setSearhData (data, up) {
      if (!up) {
        this.searhData = data;
      } else {
        this.searhData = data;
        this.getTableData(1, this.searhData);
      }
    },
    //选中的数据
    setSelectData (data) {
      this.$parent.setSelectData(data)
    },
    //进入详情
    async setdialog (data) {
      this.$parent.setdialog(data);
    },
  },
  mounted () {
    this.getTableData(1, {})
  },
  components: {
    'v-table': table
  }
}
</script>

<style scoped>
</style>